package br.com.hsp.system.repository;

import java.util.List;

import javax.persistence.EntityManager;
import javax.persistence.Query;

import br.com.hsp.users.MedicoClinica;

public class MedicoClinicaRepository {
	
	private EntityManager manager ;
	
	public MedicoClinicaRepository ( EntityManager manager ) {
		this.manager = manager ;
	}
	
	public void add(MedicoClinica medicoClinica) {
		this.manager.persist(medicoClinica);
	}
	
	public void remove(Long id) {
		MedicoClinica medicoClinica = this.procura(id);
		this.manager.remove(medicoClinica);
	}
	
	public MedicoClinica atualiza(MedicoClinica medicoClinica) {
		return this.manager.merge(medicoClinica);
	}
	
	public MedicoClinica procura(Long id) {
		return this.manager.find(MedicoClinica.class, id);
	}
	
	public List<MedicoClinica> getLista() {
		Query query = this.manager.createQuery("SELECT x from MedicoClinica x");
		return query.getResultList();
	}
}
